<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title>666</title>
    <style>
        /* the important bits */
        .entryDirection li {
            -webkit-perspective: 400px;
            perspective: 400px;
        }

        .info {
            -webkit-transform: rotate3d(1, 0, 0, 90deg);
            transform: rotate3d(1, 0, 0, 90deg);
            width: 100%;
            height: 100%;
            padding: 20px;
            position: absolute;
            top: 0;
            left: 0;
            border-radius: 4px;
            pointer-events: none;
            background-color: rgba(26, 188, 156, 0.9);
        }

        .in-top .info {
            -webkit-transform-origin: 50% 0%;
            transform-origin: 50% 0%;
            -webkit-animation: in-top 300ms ease 0ms 1 forwards;
            animation: in-top 300ms ease 0ms 1 forwards;
        }

        .in-right .info {
            -webkit-transform-origin: 100% 0%;
            transform-origin: 100% 0%;
            -webkit-animation: in-right 300ms ease 0ms 1 forwards;
            animation: in-right 300ms ease 0ms 1 forwards;
        }

        .in-bottom .info {
            -webkit-transform-origin: 50% 100%;
            transform-origin: 50% 100%;
            -webkit-animation: in-bottom 300ms ease 0ms 1 forwards;
            animation: in-bottom 300ms ease 0ms 1 forwards;
        }

        .in-left .info {
            -webkit-transform-origin: 0% 0%;
            transform-origin: 0% 0%;
            -webkit-animation: in-left 300ms ease 0ms 1 forwards;
            animation: in-left 300ms ease 0ms 1 forwards;
        }

        .out-top .info {
            -webkit-transform-origin: 50% 0%;
            transform-origin: 50% 0%;
            -webkit-animation: out-top 300ms ease 0ms 1 forwards;
            animation: out-top 300ms ease 0ms 1 forwards;
        }

        .out-right .info {
            -webkit-transform-origin: 100% 50%;
            transform-origin: 100% 50%;
            -webkit-animation: out-right 300ms ease 0ms 1 forwards;
            animation: out-right 300ms ease 0ms 1 forwards;
        }

        .out-bottom .info {
            -webkit-transform-origin: 50% 100%;
            transform-origin: 50% 100%;
            -webkit-animation: out-bottom 300ms ease 0ms 1 forwards;
            animation: out-bottom 300ms ease 0ms 1 forwards;
        }

        .out-left .info {
            -webkit-transform-origin: 0% 0%;
            transform-origin: 0% 0%;
            -webkit-animation: out-left 300ms ease 0ms 1 forwards;
            animation: out-left 300ms ease 0ms 1 forwards;
        }

        @-webkit-keyframes in-top {
            from {
                -webkit-transform: rotate3d(-1, 0, 0, 90deg);
                transform: rotate3d(-1, 0, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }

        @keyframes in-top {
            from {
                -webkit-transform: rotate3d(-1, 0, 0, 90deg);
                transform: rotate3d(-1, 0, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @-webkit-keyframes in-right {
            from {
                -webkit-transform: rotate3d(0, -1, 0, 90deg);
                transform: rotate3d(0, -1, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @keyframes in-right {
            from {
                -webkit-transform: rotate3d(0, -1, 0, 90deg);
                transform: rotate3d(0, -1, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @-webkit-keyframes in-bottom {
            from {
                -webkit-transform: rotate3d(1, 0, 0, 90deg);
                transform: rotate3d(1, 0, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @keyframes in-bottom {
            from {
                -webkit-transform: rotate3d(1, 0, 0, 90deg);
                transform: rotate3d(1, 0, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @-webkit-keyframes in-left {
            from {
                -webkit-transform: rotate3d(0, 1, 0, 90deg);
                transform: rotate3d(0, 1, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @keyframes in-left {
            from {
                -webkit-transform: rotate3d(0, 1, 0, 90deg);
                transform: rotate3d(0, 1, 0, 90deg);
            }
            to {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
        }
        @-webkit-keyframes out-top {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(-1, 0, 0, 104deg);
                transform: rotate3d(-1, 0, 0, 104deg);
            }
        }
        @keyframes out-top {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(-1, 0, 0, 104deg);
                transform: rotate3d(-1, 0, 0, 104deg);
            }
        }
        @-webkit-keyframes out-right {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(0, -1, 0, 104deg);
                transform: rotate3d(0, -1, 0, 104deg);
            }
        }
        @keyframes out-right {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(0, -1, 0, 104deg);
                transform: rotate3d(0, -1, 0, 104deg);
            }
        }
        @-webkit-keyframes out-bottom {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(1, 0, 0, 104deg);
                transform: rotate3d(1, 0, 0, 104deg);
            }
        }
        @keyframes out-bottom {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(1, 0, 0, 104deg);
                transform: rotate3d(1, 0, 0, 104deg);
            }
        }
        @-webkit-keyframes out-left {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(0, 1, 0, 104deg);
                transform: rotate3d(0, 1, 0, 104deg);
            }
        }
        @keyframes out-left {
            from {
                -webkit-transform: rotate3d(0, 0, 0, 0deg);
                transform: rotate3d(0, 0, 0, 0deg);
            }
            to {
                -webkit-transform: rotate3d(0, 1, 0, 104deg);
                transform: rotate3d(0, 1, 0, 104deg);
            }
        }
        /* you can ignore this ones */
        .entryDirection {
            padding: 0;
            margin: 0 0 50px;
        }
        .entryDirection:after {
            content: "";
            display: table;
            clear: both;
        }

        .entryDirection li {
            position: relative;
            float: left;
            width: 200px;
            height: 200px;
            margin: 5px;
            padding: 0;
            list-style: none;
        }
        .entryDirection li a {
            display: inline-block;
            vertical-align: top;
            text-decoration: none;
            border-radius: 4px;
        }
        .entryDirection li h3 {
            margin: 0;
            font-size: 16px;
            color: rgba(255, 255, 255, 0.9);
        }
        .entryDirection li p {
            font-size: 12px;
            line-height: 1.5;
            color: rgba(255, 255, 255, 0.8);
        }
        .entryDirection li .normal {
            width: 100%;
            height: 100%;
            background-color: #ECF0F1;
            color: rgba(52, 73, 94, 0.6);
            box-shadow: inset 0 2px 20px #e6ebed;
            text-align: center;
            font-size: 50px;
            line-height: 200px;
        }
        .entryDirection li .normal svg {
            pointer-events: none;
            width: 50px;
        }
        .entryDirection li .normal svg path {
            fill: rgba(52, 73, 94, 0.2);
        }

        * {
            box-sizing: border-box;
        }

        body {
            background-color: #fff;
        }

        h1 {
            margin: 0 auto 5px;
            text-align: center;
        }

        h3 {
            font-family: 'Bree Serif', serif;
        }

        .container {
            width: 840px;
            margin: 0 auto;
        }

        header {
            font-family: 'Bree Serif', serif;
            text-align: center;
            margin: 50px 0 25px;
            color: #34495E;
        }
        header p {
            margin: 0;
            color: rgba(52, 73, 94, 0.4);
        }

    </style>
</head>
<body>
    <div class='container'>
        <ul class="entryDirection">
            <li>
                <a class='normal' href='#'></a>
                <div class='info'>
                    <h3>我才是最帅的</h3>
                </div>
            </li>
        </ul>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        var getDirection = function (ev, obj) {
                    var w = obj.get(0).offsetWidth,
                        h = obj.get(0).offsetHeight,
                        x = (ev.pageX - obj.get(0).offsetLeft - (w / 2) * (w > h ? (h / w) : 1)),
                        y = (ev.pageY - obj.get(0).offsetTop - (h / 2) * (h > w ? (w / h) : 1)),
                        d = Math.round( Math.atan2(y, x) / 1.57079633 + 5 ) % 4;
                    return d;
                };

                var addClass = function ( ev, obj, state ) {
                    var direction = getDirection( ev, obj ),
                        class_suffix = "";
                        obj.get(0).className = "";
                        
                        switch ( direction ) {
                            case 0 : class_suffix = '-top';    break;
                            case 1 : class_suffix = '-right';  break;
                            case 2 : class_suffix = '-bottom'; break;
                            case 3 : class_suffix = '-left';   break;
                        }
                        obj.get(0).classList.add( state + class_suffix );
                };

                // bind events
                 $(".entryDirection li").hover(
                        function(ev){
                            addClass( ev, $(this), 'in' );
                        },
                        function(ev){
                            addClass( ev, $(this), 'out' );
                        }
                    )
              

    </script>
</body>
</html>

